package com.mtsmda.jpa.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "CARS")
@NamedQueries(value = {
		@NamedQuery(name = "Car.getAll", query = "SELECT c FROM Car c"),
		@NamedQuery(name = "Car.deleteAll", query = "DELETE FROM Car c")/*,
		@NamedQuery(name = "Car.truncate", query = "TRUNCATE TABLE Car")*/ })
public class Car {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID_CAR")
	private Integer idCar;

	@Column(name = "NAME_CAR", length = 25, nullable = false)
	private String nameCar;

	@Column(name = "RELEASE_DATE_CAR", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date releaseDate;

	@Column(name = "COST_CAR", nullable = false)
	private Float cost;

	public Car() {

	}

	public Car(String nameCar, Date releaseDate, Float cost) {
		setNameCar(nameCar);
		setCost(cost);
		setReleaseDate(releaseDate);
	}

	public Integer getIdCar() {
		return idCar;
	}

	public void setIdCar(Integer idCar) {
		this.idCar = idCar;
	}

	public String getNameCar() {
		return nameCar;
	}

	public void setNameCar(String nameCar) {
		this.nameCar = nameCar;
	}

	public Date getReleaseDate() {
		return releaseDate;
	}

	public void setReleaseDate(Date releaseDate) {
		this.releaseDate = releaseDate;
	}

	public Float getCost() {
		return cost;
	}

	public void setCost(Float cost) {
		this.cost = cost;
	}

	@Override
	public String toString() {
		return "Car [idCar=" + idCar + ", nameCar=" + nameCar
				+ ", releaseDate=" + releaseDate + ", cost=" + cost + "]";
	}

}